﻿using Model.Modules;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Newtonsoft.Json;
using PropertyChanged;

namespace Model.Modules
{
    public class Imagedefectinfo : INotifyPropertyChanged
    {
        public Imagedefectinfo()
        {
            Image_DefectList = new ObservableCollection<image_defect>();
            IsFirst = false;
            CurrentImage = Image;
            CurrentImageBmp = ImageBmp;
        }
        public ObservableCollection<image_defect> Image_DefectList
        {
            get { return image_DefectList; }
            set
            {
                image_DefectList = value;
                AutoDetectCount = Image_DefectList.Where(t => t.confidence < 1).Count();
                ReviewDetectCount = Image_DefectList.Where(t => t.confidence == 1).Count();
            }
        }
        private ObservableCollection<image_defect> image_DefectList;

        [AlsoNotifyFor("CurrentImage")]
        public image Image { get; set; }
        public image Image2 { get; set; }
        public image Image3 { get; set; }
        public image Image4 { get; set; }
        public BitmapImage ImageBmp { get; set; }
        public BitmapImage Image2Bmp { get; set; }
        public BitmapImage Image3Bmp { get; set; }
        public BitmapImage Image4Bmp { get; set; }
        public bool IsFirst { get; set; }
        public image CurrentImage { get; set; }
        public BitmapImage CurrentImageBmp { get; set; }
        public image_defect CurrentDefect { get; set; }
        public int AutoDetectCount { get; set; }
        public int ReviewDetectCount { get; set; }
        public ImageStatus ImageStatus { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        public Imagedefectinfo Clone()
        {
            return JsonConvert.DeserializeObject<Imagedefectinfo>(JsonConvert.SerializeObject(this));
        }
        public void UpdateDefectCount()
        {
            AutoDetectCount = Image_DefectList.Where(t => t.confidence < 1 && t.is_user_delete != true).Count();
            ReviewDetectCount = Image_DefectList.Where(t => t.confidence == 1 && t.is_user_delete != true).Count();
        }
    }
    public enum ImageStatus
    {
        Normal,
        Arichived,
        Cropped
    }

    public class Imageinfo : INotifyPropertyChanged
    {

        public ObservableCollection<image_defect> Image_DefectList { get; set; }
        public image Image { get; set; }
        public image Image2 { get; set; }
        public image Image3 { get; set; }
        public image Image4 { get; set; }
        public BitmapImage ImageBmp { get; set; }
        public BitmapImage Image2Bmp { get; set; }
        public BitmapImage Image3Bmp { get; set; }
        public BitmapImage Image4Bmp { get; set; }
        public bool isFirst = false;
        public bool IsFirst { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        //public Imagedefectinfo Clone() { 
        //    return new Imagedefectinfo
        //    {
        //        image=new image
        //        {

        //        }
        //    }

        //}
    }


}
